public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = Thread.currentThread();
        System.out.println(t1.getName());

        Thread t2 = new Thread(()->{
            try {
                t1.join();
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("t2 结束");
        });
        t2.start();


        for (int i = 0; i < 5; i++) {
            Thread.sleep(1000);
        }

        System.out.println("main 结束");
    }
}
